package com.lcc.lynx.jdbc.qw;

import com.lcc.lynx.jdbc.annotation.Table;
import com.lcc.lynx.jdbc.pojo.TablePojo;
import lombok.Getter;

/**
 * @author lcc
 * @date 2025/7/23 14:01
 */
public abstract class TableDef {

    @Getter
    protected String tableName;
    protected Class<? extends TablePojo> dvClass;

    public TableDef(Class<? extends TablePojo> dvClass) {
        this.dvClass = dvClass;
        Class<?> superclass = dvClass.getSuperclass();
        Table table = superclass.getAnnotation(Table.class);
        if (table != null) {
            this.tableName = table.value();
        } else {
            throw new RuntimeException("请使用@Table注解指定表名: " + superclass.getSimpleName());
        }
    }

    public Class<?> getDvClass() {
        return dvClass;
    }
}
